/**
 * 此文件是平台属性的接口文件
 */

// 1. 引入异步对象
import request from '@/utils/request'
import type { attrInfoModel } from './model/attrModel'
import type { CategoryIdsModel } from './model/categoryModel'
// 2. 使用枚举定义后端接口
enum Api {
  // 1. 获取平台属性列表
  getAttrListApi = '/admin/product/attrInfoList',
  // 2. 删除某属性
  deleteAttrValueApi = '/admin/product/deleteAttr',
  // 3. 添加属性
  saveAttrInfoApi = '/admin/product/saveAttrInfo',
  // 4. 更新属性

}
// 3. 书写接口函数
// 3.1 根据一二三级导航Id 获取对应的属性列表
export const reqGetAttrListData = ({ category1Id, category2Id, category3Id }:CategoryIdsModel) => request.get<any,attrInfoModel[]>(Api.getAttrListApi + `/${category1Id}/${category2Id}/${category3Id}`)

// 3.2 根据某属性id删除某属性
export const reqDeleteAttrInfo = (attrId:number) => {
  return request.delete<any,null>(Api.deleteAttrValueApi +`/${attrId}`)
}

// 3.3 添加属性
export const reqSaveAttrInfoData = (attrInfo:attrInfoModel) => {
  return request.post<any,null>(Api.saveAttrInfoApi,attrInfo)
}